package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IHousekeepingServFeeServiceDao;
import com.java110.dto.housekeeping.HousekeepingServFeeDto;
import com.java110.intf.cart.IHousekeepingServFeeInnerServiceSMO;
import com.java110.po.housekeeping.HousekeepingServFeePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 服务费用管理内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingServFeeInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingServFeeInnerServiceSMO {

    @Autowired
    private IHousekeepingServFeeServiceDao housekeepingServFeeServiceDaoImpl;


    @Override
    public int saveHousekeepingServFee(@RequestBody HousekeepingServFeePo housekeepingServFeePo) {
        int saveFlag = 1;
        housekeepingServFeeServiceDaoImpl.saveHousekeepingServFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingServFeePo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingServFee(@RequestBody  HousekeepingServFeePo housekeepingServFeePo) {
        int saveFlag = 1;
         housekeepingServFeeServiceDaoImpl.updateHousekeepingServFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingServFeePo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingServFee(@RequestBody  HousekeepingServFeePo housekeepingServFeePo) {
        int saveFlag = 1;
        housekeepingServFeePo.setStatusCd("1");
        housekeepingServFeeServiceDaoImpl.updateHousekeepingServFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingServFeePo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingServFeeDto> queryHousekeepingServFees(@RequestBody  HousekeepingServFeeDto housekeepingServFeeDto) {

        //校验是否传了 分页信息

        int page = housekeepingServFeeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServFeeDto.setPage((page - 1) * housekeepingServFeeDto.getRow());
        }

        List<HousekeepingServFeeDto> housekeepingServFees = BeanConvertUtil.covertBeanList(housekeepingServFeeServiceDaoImpl.getHousekeepingServFeeInfo(BeanConvertUtil.beanCovertMap(housekeepingServFeeDto)), HousekeepingServFeeDto.class);

        return housekeepingServFees;
    }


    @Override
    public int queryHousekeepingServFeesCount(@RequestBody HousekeepingServFeeDto housekeepingServFeeDto) {
        return housekeepingServFeeServiceDaoImpl.queryHousekeepingServFeesCount(BeanConvertUtil.beanCovertMap(housekeepingServFeeDto));    }

    @Override
    public String queryHousekeepingServDefaultFee(String shopId,String servId) {

        Map<String,String> map = new HashMap<>(  );
        map.put( "shopId",shopId );
        map.put( "servId",servId );

        return  housekeepingServFeeServiceDaoImpl.queryHousekeepingServDefaultFee(map);
    }

    public IHousekeepingServFeeServiceDao getHousekeepingServFeeServiceDaoImpl() {
        return housekeepingServFeeServiceDaoImpl;
    }

    public void setHousekeepingServFeeServiceDaoImpl(IHousekeepingServFeeServiceDao housekeepingServFeeServiceDaoImpl) {
        this.housekeepingServFeeServiceDaoImpl = housekeepingServFeeServiceDaoImpl;
    }
}
